import {actionType} from './index'
import {Jsonp,axiosGet} from '@/axios'

const changeWeather = (weatherInfo, weatherPicUrl) => ({
    type: actionType.CHANGE_WEATHER,
    weatherInfo,
    weatherPicUrl
})
export const getCurrTime = (currTime) => ({
    type: actionType.GET_CURR_TIME,
    currTime
})
export const getWeatherInfo = () => {
    return (dispatch) => {
        const params = {url:'/weather.json'}
        axiosGet(params).then((res)=>{
            console.log(res)
            if (res.status === 'success'){
                const weatherInfo = res.results[0]['weather_data'][0].weather
                const weatherPicUrl = res.results[0]['weather_data'][0].dayPictureUrl
                dispatch(changeWeather(weatherInfo,weatherPicUrl))
            }
        })
    }
}